package com.woniu.darryringmall.ucenter.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.darryringmall.front.entity.Order;
import com.woniu.darryringmall.front.entity.User;
import com.woniu.darryringmall.front.service.CategoryService;
import com.woniu.darryringmall.front.service.GoodsService;
import com.woniu.darryringmall.front.service.OrderService;
import com.woniu.darryringmall.front.service.ViewOrderService;
import com.woniu.darryringmall.utils.ResponseData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;

@Slf4j
@Controller("ucenterOrder")
@RequestMapping("ucenter/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ViewOrderService viewOrderService;

    //根据用户id分页查询订单
    @PostMapping("list1")
//    @GetMapping("list1")
    @ResponseBody
    public ResponseData list(Integer current , HttpSession session) {
        if (current == null) {
            current = 1;
        };
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("userid", ((User)session.getAttribute("user")).getId());
        Page<Order> page = new Page<>(current, 2);
        page=orderService.page(page,queryWrapper);
        return new ResponseData(page);
    }

}
